package cn.com.elite;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class Util {
	private static final Log log=LogFactory.getLog(Util.class);
	public static String getERRO(Exception e){
		String str="";
		try{
            StringWriter sw=new StringWriter();  
            e.printStackTrace(new PrintWriter(sw,true));  
            str=sw.toString(); 	
		}catch(Exception e1){
			str=e.toString();
			log.error("getERRO:"+e1.toString());
		}
		return str;
	}
	public static void main(String[] args){
		String str="";
		int i=0;
		String s="0";
		Random r=new Random();
		while (i<10){
			switch(r.nextInt(9)){
			case (0): s = "0"; break;
		    case (1): s = "1"; break;
		    case (2): s = "2"; break;
		    case (3): s = "3"; break;
		    case (4): s = "4"; break;
		    case (5): s = "5"; break;
		    case (6): s = "6"; break;
		    case (7): s = "7"; break;
		    case (8): s = "8"; break;
		    case (9): s = "9"; break;
			}
			i++;
			str=str+s;
		}
		System.out.print(str);
		
	}
	public static String getString(Object obj){
		if(obj==null){
			return "";
		}else{
			return obj.toString().replace(" ","");
		}
	}
	public static String ReturnCode1(){
		SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");//设置日期格式
		String str=df.format(new Date());
		int i=0;
		String s="0";
		Random r=new Random();
		while (i<8){
			switch(r.nextInt(9)){
			case (0): s = "0"; break;
		    case (1): s = "1"; break;
		    case (2): s = "2"; break;
		    case (3): s = "3"; break;
		    case (4): s = "4"; break;
		    case (5): s = "5"; break;
		    case (6): s = "6"; break;
		    case (7): s = "7"; break;
		    case (8): s = "8"; break;
		    case (9): s = "9"; break;
			}
			i++;
			str=str+s;
		}
		return str;
	}
	public static String ReturnCode(){
		Random r=new Random();
		int i=0;
		String str="";
		String s="0";
		while (i<20){
			switch(r.nextInt(63)){
			case (0): s = "0"; break;
		    case (1): s = "1"; break;
		    case (2): s = "2"; break;
		    case (3): s = "3"; break;
		    case (4): s = "4"; break;
		    case (5): s = "5"; break;
		    case (6): s = "6"; break;
		    case (7): s = "7"; break;
		    case (8): s = "8"; break;
		    case (9): s = "9"; break;
		    case (10): s = "a"; break;
		    case (11): s = "b"; break;
		    case (12): s = "c"; break;
		    case (13): s = "d"; break;
		    case (14): s = "e"; break;
		    case (15): s = "f"; break;
		    case (16): s = "g"; break;
		    case (17): s = "h"; break;
		    case (18): s = "i"; break;
		    case (19): s = "j"; break;
		    case (20): s = "k"; break;
		    case (21): s = "l"; break;
		    case (22): s = "m"; break;
		    case (23): s = "n"; break;
		    case (24): s = "o"; break;
		    case (25): s = "p"; break;
		    case (26): s = "q"; break;
		    case (27): s = "r"; break;
		    case (28): s = "s"; break;
		    case (29): s = "t"; break;
		    case (30): s = "u"; break;
		    case (31): s = "v"; break;
		    case (32): s = "w"; break;
		    case (33): s = "L"; break;
		    case (34): s = "x"; break;
		    case (35): s = "y"; break;
		    case (36): s = "z"; break;
		    case (37): s = "A"; break;
		    case (38): s = "B"; break;
		    case (39): s = "C"; break;
		    case (40): s = "D"; break;
		    case (41): s = "E"; break;
		    case (42): s = "F"; break;
		    case (43): s = "G"; break;
		    case (44): s = "H"; break;
		    case (45): s = "I"; break;
		    case (46): s = "L"; break;
		    case (47): s = "J"; break;
		    case (48): s = "K"; break;
		    case (49): s = "M"; break;
		    case (50): s = "N"; break;
		    case (51): s = "O"; break;
		    case (52): s = "P"; break;
		    case (53): s = "Q"; break;
		    case (54): s = "R"; break;
		    case (55): s = "S"; break;
		    case (56): s = "T"; break;
		    case (57): s = "U"; break;
		    case (58): s = "V"; break;
		    case (59): s = "W"; break;
		    case (60): s = "X"; break;
		    case (61): s = "Y"; break;
		    case (62): s = "Z"; break;
			}
			i++;
			str=s+str;
		}
		return str;
	}
}
